Imports System.Collections.Generic
Imports System.Drawing
Imports System.Windows.Forms
Imports Vintasoft.Pdf
Imports Vintasoft.Pdf.Content.TextExtraction
Imports Vintasoft.Pdf.Tree.Fonts

Namespace Pdf
	Public Partial Class ViewDocumentFontsForm
		Inherits Form

		#Region "Fields"

		Private _fonts As IList(Of PdfFont)
		Private _document As PdfDocument

		#End Region



		#Region "Constructor"

		Public Sub New(document As PdfDocument)
			InitializeComponent()
			_document = document
			_fonts = document.Fonts
			For i As Integer = 0 To _fonts.Count - 1
				fontComboBox.Items.Add(String.Format("[№{1}] {0} ({2})", _fonts(i).FontName, _fonts(i).ObjectNumber, _fonts(i).FontType))
			Next
			fontComboBox.SelectedIndex = 0
		End Sub


		#End Region



		#Region "Methods"

		Private Sub fontComboBox_SelectedIndexChanged(sender As Object, e As EventArgs)
			pdfFontViewerControl.PdfFont = _fonts(fontComboBox.SelectedIndex)
		End Sub

		Private Sub cellSizeNumericUpDown_ValueChanged(sender As Object, e As EventArgs)
			Dim sz As Integer = CInt(Math.Truncate(cellSizeNumericUpDown.Value))
			pdfFontViewerControl.CellSize = New Size(sz, sz)
		End Sub

		Private Sub pdfFontViewerControl1_MouseMove(sender As Object, e As MouseEventArgs)
			Dim symbol As TextSymbol = pdfFontViewerControl.GetTextSymbol(e.Location)
			If symbol Is Nothing Then
				toolStripStatusLabel.Text = ""
			Else
				toolStripStatusLabel.Text = String.Format("Symbol: '{0}'; Code: {1}", symbol.Symbol, symbol.SymbolCode)
			End If
		End Sub

		#End Region

	End Class
End Namespace
